/*
 * This file is part of aKoustiK.

 * aKoustiK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * aKoustiK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with aKoustiK.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PLAYLISTTABLEMODEL_H
#define PLAYLISTTABLEMODEL_H

#include <QtCore/QAbstractTableModel>

#include <playlist.h>

class PlaylistTableModel : public QAbstractTableModel {
    Q_OBJECT
public:
    PlaylistTableModel(QObject* parent);
    ~PlaylistTableModel();

    // Drag-and-Drop:
    Qt::DropActions supportedDropActions() const;
    QStringList mimeTypes() const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
    Qt::DropActions supportedDragActions() const;
    QMimeData* mimeData(const QModelIndexList &indexes) const;

private:
    // TableModel:
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

    // fields:
    Playlist* mPlaylist;

    // methods:
    void emitDataChanged(int index);

public slots:
    void deleteItems(const QModelIndexList& list);

private slots:
    void itemUpdated(int newIndex, int oldIndex);
    void beforePlaylistAppend(int index, int size);
    void afterPlaylistAppend();

};

#endif
